//Book.h:interface for the Book class.
#if!defined BOOK_H
#define BOOK_H
#include<iostream>
using namespace std;
class Book{
public:
Book(string number="",string name="", string type="",string author="",
     string publish="", string pub_time="", float price=0, bool onshelt=true,
     int total count=o);
virtual ~Book() ;
string getNum();
void setNum (string number);
string getName ();
void setNameng number);
string getName ();
void setName (string name) ;
string getType() ;
void setType (string type) ;
string getAuthor() ;
void setAuthor (string author) ;
string getPublish() ;
void setPublish (string publish) ;
string getPubTime () ;
void setPubTime (string pub time) ;
float getPrice () ;
void setPrice (float price) ;
int getTotalCount () ;
void setTotalCount (int total count) ;
bool getBookOnShelf();
void setName (string name) ;
string getType() ;
void setType (string type) ;
string getAuthor() ;
void setAuthor (string author) ;
string getPublish() ;
void setPublish (string publish) ;
string getPubTime () ;
void setPubTime (string pub time) ;
float getPrice () ;
void setPrice (float price) ;
int getTotalCount () ;
void setTotalCount (int total count) ;
bool getBookOnShelf();
void setBookonShelf (bool onshelf);
void bookShow() ;
void readFromFile (fstream &);
void writeToFile (fstream &) const;
friend istream& operator>>(istream &istrm, Book &book);
friend ostream& operator<< (ostream &ostrm,const Book sbook.
private:
string bookNum;//图书条形码
string bookName;//图书名称
string bookType;//图书类型
string bookAuthor;//作者
string bookPublish;//出 版社
string bookPubTime;//出版时间
float bookPrice;//图书价格
float bookPrice;//是否在架
bool bookOnShelf;//图书被借次数
int totalCount;
}
#endif
//ook.cpp: implementation for the Book class .
# include "Book.h"
# include<fstream>
# include<string>
# include<iostream>
using namespace std;
Bok::Book (string number, string name, string type, string author, stringpublish, string pub_ time, float price, bool onshelf, int total_ count)
bookNum= number ;//图书条形码
bookName= name ;//图书名称
bookType= type;//图书类型
bookAuthor=author ;//作者
bookPublish=publish;//出版社
bookPubTime=pub time;//出版时间
bookPrice=price;//图书价格
bookOnShelf=onshelf ;//是否在架
totalCount=total count;//图书被借次数
Book: :~Book(){ }bookNum= number ;//图书条形码
bookName= name ;//图书名称
bookType= type;//图书类
bookAuthor=author ;//作者
bookPublish=publish//出版社
bookPubTime=pub time;//出版时间
bookPrice=price;//图书价格
bookOnShelf=onshelf ;//在架
totalCount=total count;//图书被借次数
Book: :~Book(){ }
istreams operator>> (istream Gistrm, Book 6book)
cout<< "请输人: "<< endl;
cout<<"图书条形码(最多9个数字) :";
istrm>> book .boo kNum ;
cout<<"图书名称(最多20个汉字):";
istrm> > book .boo kName;
cout<<"图书类型(最多10个汉字):";
istrm>>book.bookType;
cout<<"作者(最多5个汉字):";
ist rm>> book .bookAuthoei
cout<<"出版社(最多10个汉字):";
istrm>>book .bookPublish;
cout<<"出版时间(输人格式:2014:09:01):";
ist rm> >book .bookPubTime;
cout<<"图书价格(浮点数):";
istrm>>book bookPrice;
cout<<"是否在架(1:在架，0:借出):";
istrm> >book .bookOnShelf;
cout<<"图书被借次数(整数):";
ist rm>>book.totalCount;
return istrm;
ostream& operator« (ostream &ostrm,const Book &book)
ostrm<"k15 ÃJ 59:"< book . bookNum< "Lt"
« "15 R FK :"<< book .bookName<«"'t"
«"5 Ж EL :"< book .bookType<"lt"
« "/F# :"<< book. bookAuthor<"lt"
<< " JTtt : "<<book.bookPublish< "lt"
< "H HfER-f [ï] :"<< book . bookPubTime«"lt"
<<"B =; yr t :"<< book . bookPrice<<"lt"
<<"是否在架:"<< (book bookonshelf?"在架":"借出"1<<"\t”<<"图书被借次数:"<<book . totalCounte<endli
return ostrm;
}

